package com.yh.threadTest.task;

/**
 * @ClassName Test2
 * @Description TODO
 * @Author 0715-YuHao
 * @Date 2020/11/14 14:46
 */
public class Test2 {

    public static void main(String[] args) {
        ThreadA r1 = new ThreadA();
        ThreadB r2 = new ThreadB();
        ThreadC r3 = new ThreadC();
        ThreadD r4 = new ThreadD();

        Thread t1 = new Thread(r1, "A");
        Thread t2 = new Thread(r2, "B");
        Thread t3 = new Thread(r3, "C");
        Thread t4 = new Thread(r4, "D");

        t1.start();
        t2.start();
        t3.start();
        t4.start();

        while (true) {
            if (r1.isFlag() && r2.isFlag() && r3.isFlag() && r4.isFlag()) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                break;
            }
        }

        System.out.println("E执行");
    }
}
